﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Slf;

namespace SLF.Test
{
  [TestClass]
  public class TestLoggerTest
  {
    [TestMethod]
    public void RobustnessTest()
    {
      TestLogger logger = new TestLogger();

      List<string> failures = ExploratoryTester.TestILogger(logger);

      Assert.AreEqual(0, failures.Count,
        failures.Count != 0 ? failures.Aggregate((s1, s2) => s1 + System.Environment.NewLine + s2) : "");

    }


    [TestMethod]
    public void Internal_Cache_Should_Not_Be_Exposed()
    {
      var logger = new TestLogger();
      logger.Log(LogLevel.Info, "hello");
      logger.Log(LogLevel.Warn, "world");

      Assert.AreEqual(2, logger.LoggedItems.Count);
      logger.LoggedItems.Clear();
      Assert.AreEqual(2, logger.LoggedItems.Count);
    }


    [TestMethod]
    public void Restting_Logger_Should_Clear_Cached_Items()
    {
      var logger = new TestLogger();
      logger.Log(LogLevel.Info, "hello");
      logger.Log(LogLevel.Warn, "world");

      Assert.AreEqual(2, logger.LoggedItems.Count);
      logger.Reset();
      Assert.AreEqual(0, logger.LoggedItems.Count);
    }



  }
}
